namespace OrderingSystem.API.Models
{
    /// <summary>
    /// 统一返回格式
    /// </summary>
    public class R
    {
        /// <summary>
        /// 状态码：0成功，1失败
        /// </summary>
        public int code { get; set; }

        /// <summary>
        /// 返回消息
        /// </summary>
        public string msg { get; set; }

        /// <summary>
        /// 返回数据
        /// </summary>
        public object data { get; set; }

        /// <summary>
        /// 创建成功返回结果
        /// </summary>
        public static R Ok(string msg = "操作成功")
        {
            return new R { code = 0, msg = msg };
        }

        /// <summary>
        /// 创建成功返回结果（带数据）
        /// </summary>
        public static R Ok(object data, string msg = "操作成功")
        {
            return new R { code = 0, msg = msg, data = data };
        }

        /// <summary>
        /// 创建失败返回结果
        /// </summary>
        public static R Error(string msg = "操作失败")
        {
            return new R { code = 1, msg = msg };
        }
    }
} 